package com.questionnaires.service;

import com.questionnaires.exception.NotExistsException;
import com.questionnaires.exception.NotUniqueException;
import com.questionnaires.model.User;

import java.util.List;

/**
 * Interface used to define methods for user related operations.
 *
 * @author ioana.ruca@gmail.com
 */
public interface UserService {

    /**
     * Saves or updates a user.
     *
     * @param user the user to be processed.
     * @throws NotUniqueException thrown if a user with the same username already exists.
     */
    void saveOrUpdate(User user) throws NotUniqueException;

    /**
     * Retrieves all the existing users.
     *
     * @return a list of all the users
     */
    List<User> findAll();

    /**
     * Deletes the user with the specified id.
     * @param id the given user's id
     * @throws NotExistsException thrown when no user exists with this id
     */
    void deleteById(Long id) throws NotExistsException;
    
    User findByName(String username);
}
